<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=no" />
<title></title>
<link rel="shortcut icon" href="Images/ico/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link type="text/css" rel="stylesheet" href="/layui/css/layui.css"  media="all">
<script type="text/javascript" src="/layui/layui.js" charset="utf-8"></script>
<script src="/js/jquery.min.js" type="text/javascript"></script>
<script src="/js/xcity.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/layui-post.js"></script>
<style type="text/css">
.box-active{position: fixed!important;background:#fff;width:93%;margin: 0;z-index:2;top:50px;}
</style>
</head>
<body>
<div class="ng-scope">
  <header class="ng-scope" style="">
    <h4 class="title-order">
      <a class="title-top" href="javascript:window.history.back();"></a>
      <a class="title-center">积分记录</a>
      <a class="title-right" href="/index"></a>
    </h4>
  </header>
</div>
<div class="jfheader" style="margin-top: 52px;">
<div class="guize">积分使用规则</div>
  <div class="jfnum"><span style="font-size: 1.5rem;color:#fff;" id="jfnum">0</span><span>个</span></div>
<div class="jfsub">小积分，有大用，多领一些屯起来！</div>
<div class="jfgl">
    <ul id="integralType">
        <li data-value=""><a>全部</a></li>
        <li data-value="1"><a>收入</a></li>
        <li data-value="2"><a>支出</a></li>
    </ul>
</div>
</div>
<div class="clear"></div>
<div class="kbox"></div>
<div class="jfbox"></div>
<div class="cartempty ng-scope ng-hide">
    <h3>暂无数据</h3>
</div>
</body>
<script>
$.ajaxSetup({contentType: "application/json; charset=utf-8"});
var userInfo = $.parseJSON(sessionStorage.getItem("userInfo"));
window.addEventListener('scroll', function(){
    let t = $('body, html').scrollTop();   // 目前监听的是整个body的滚动条距离
    if(t>132)  $('.jfgl').addClass('box-active')
    else  $('.jfgl').removeClass('box-active')
})
layui.use(['layer','form','element','util'], function(){
    $("#jfnum").html(userInfo.integral)
    layui.util.fixbar({
        top:true,
        css: { right: 15, bottom: 105 },
        showHeight:100,
        click: function (type) {
            if (type === 'top') {
                $('.layui-fluid').animate({//主要代码
                    scrollTop: 0
                }, 200);
            }
        }
    });
    showData();
})
function showData(type){
    var data = {userId:userInfo.userId};
    if(!isEmpty(type)) data['integralType'] = type;
    $.post("/cateringIntegral/select",JSON.stringify(data), function (res) {
        $(".jfbox").html("")
        if(res.data.length == 0) $(".cartempty").removeClass("ng-hide")
        else $(".cartempty").addClass("ng-hide")
        for(var i in res.data){
            $(".jfbox").append(
                '<div class="jfbox1">' +
                '<div class="jfbox1_L">' +
                '<img style="border-radius: 10px;" src="/images/lg.jpg" />' +
                '</div>' +
                '<div class="jfbox1_R">' +
                '<div class="jfbox1_R1">' +
                '<div class="v1">订单'+res.data[i].orderNo+(res.data[i].integralType == 1 ? '获取 ':'使用 ')+res.data[i].integralNum+' 积分</div>' +
                '<div class="v2">'+res.data[i].createTime.substring(5)+'</div>' +
                '</div>' +
                '<div class="jfbox1_R2">' +
                '<div class="v3">'+(res.data[i].integralType == 1 ? '购物积分':'购物抵现')+'</div>' +
                '<div class="v4" style="color:'+(res.data[i].integralType == 1 ? 'green':'red')+'">'+(res.data[i].integralType == 1 ? '+':'-')+res.data[i].integralNum+'</div>' +
                '</div>' +
                '</div>' +
                '<div class="clear"></div>' +
                '</div>'
            )
        }
    })
}
$("#integralType li").click(function(){
    showData($(this).attr("data-value"))
})
</script>
</html>
